import 'package:fluent_ui/fluent_ui.dart';
import 'package:provider/provider.dart';

import '../view_type.dart';
import 'test_level_view_edit.dart';
import 'test_level_view_list.dart';
import 'test_level_view_model.dart';

/// 考试等级:视图入口
class TestLevelViewMain extends StatefulWidget {
  final ViewType type;
  final String? id;

  const TestLevelViewMain({
    super.key,
    required this.type,
    this.id,
  });

  @override
  State<TestLevelViewMain> createState() => _TestLevelViewMainState();
}

class _TestLevelViewMainState extends State<TestLevelViewMain> {
  @override
  Widget build(final BuildContext context) =>
      ChangeNotifierProvider<TestLevelViewModel>(
          create: (_) => TestLevelViewModel(),
          builder: (_, __) {
            if (widget.type == ViewType.edit) {
              return TestLevelViewEdit(id: widget.id);
            }
            return TestLevelViewList();
          });
}
